package com.example.design.bilibili.prototype.shallow;

/**
 * 浅拷贝
 * 对象属性不进行拷贝
 */
public class Client {

    public static void main(String[] args) throws Exception{
        Sheep sheep = new Sheep("tom",1,"白色");
        sheep.friend = new Sheep("jack",2,"黑色");

        Sheep sheep2 = (Sheep) sheep.clone();
        Sheep sheep3 = (Sheep) sheep.clone();
        Sheep sheep4 = (Sheep) sheep.clone();
        Sheep sheep5 = (Sheep) sheep.clone();

        System.out.println("sheep2 ="+sheep2+" sheep2.hashcode="+sheep2.hashCode()+" sheep2.firend="+sheep2.friend.hashCode());
        System.out.println("sheep3 ="+sheep3+" sheep3.hashcode="+sheep3.hashCode()+" sheep3.firend="+sheep3.friend.hashCode());
        System.out.println("sheep4 ="+sheep4+" sheep4.hashcode="+sheep4.hashCode()+" sheep4.firend="+sheep4.friend.hashCode());
        System.out.println("sheep6 ="+sheep5+" sheep5.hashcode="+sheep5.hashCode()+" sheep5.firend="+sheep5.friend.hashCode());
    }
}
